<?php

use think\migration\Seeder;

class Message extends Seeder
{
    /**
     * Run Method.
     *
     * Write your database seeder using this method.
     *
     * More information on writing seeders is available here:
     * http://docs.phinx.org/en/latest/seeding.html
     */
    public function run()
    {
        $faker = Faker\Factory::create('zh_CN');
        $data = [];
        // 循环生成50条数据
        for ($j = 0; $j < 50; $j++) {
            $data[] = [
                'title'      => $faker->title(100),
                'content'      => $faker->text,
                'ip'      => $faker->ipv4,
                'create_time'  => time(),
            ];
        }
        \think\Db::name('message')->insertAll($data);
    }
}